package com.ddz.library.dialog.extend

import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import androidx.fragment.app.DialogFragment

/**
 * @param width 宽度
 * @param height 高度
 * @param gravity 位置
 * @param removeBackground 去除默认背景？
 * @param removeShade 去除默认遮罩？
 */
fun DialogFragment.initDefaultStyle(width:Int,height:Int,gravity:Int,removeBackground:Boolean,removeShade:Boolean){
    dialog?.window?.let {window ->
        window.decorView.setPadding(0,0,0,0)
        if (removeBackground) {
            window.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
        }
        if (removeShade) {
            window.attributes.dimAmount = 0f
        }
        window.attributes = window.attributes.apply {
            this.width = width
            this.height = height
            this.gravity = gravity
        }
    }
}